﻿using System;
using System.Text;
using System.Data;

namespace LKCMS.Web
{
    public partial class Bottom : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindMenu();
                BindIM();
                Bind();
            }
        }

        private void Bind()
        {
            LKCMS.Model.WebSet webset = new LKCMS.BLL.WebSet().loadConfig(LKCMS.Common.Utils.GetXmlMapPath("Configpath"));
            this.LabelAddress.Text = webset.WebUrl;
            this.LabelBA.Text = webset.WebCrod;
            this.LabelBQ.Text = webset.WebCopyright;
            this.LabelPhone.Text = webset.WebTel;
            //this.Labelgs.Text = webset.WebEmail;
        }

        private void BindMenu()
        {
            StringBuilder sb = new StringBuilder();
            LKCMS.BLL.Adbanner bll = new LKCMS.BLL.Adbanner();
            DataTable dt = bll.GetList(11, "Aid=9 and IsLock=0 ", "SortId").Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (i == 0)
                {
                    sb.Append("<a href=\"" + dt.Rows[i]["LinkUrl"].ToString() + "\">" + dt.Rows[i]["Title"] + "</a>");
                }
                else
                {
                    sb.Append("- <a href=\"" + dt.Rows[i]["LinkUrl"].ToString() + "\">" + dt.Rows[i]["Title"] + "</a>");
                }

            }
            this.LiteralMenu.Text = sb.ToString();
        }

        private void BindIM()
        {
            StringBuilder sb = new StringBuilder();
            LKCMS.BLL.IM bll = new LKCMS.BLL.IM();
            DataTable dt = bll.GetList(4, " IsLock=1 and  IMType='QQ' ", "SortId").Tables[0];
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    sb.Append("<a href='http://wpa.qq.com/msgrd?V=1&amp;Uin=" + dr["IMAccount"].ToString() + "&amp;Site=四川中青旅欢迎您&amp;Menu=yes' target='_blank'><img src=' http://wpa.qq.com/pa?p=1:" + dr["IMAccount"].ToString() + ":4'  border='0' alt='点击对话'  />" + dr["IMName"].ToString() + "</a>&nbsp;&nbsp;");
                }

            }

            this.LiteralQQ.Text = sb.ToString();

        }
    }
}